import React, { Component } from 'react'
import { Table } from 'antd'
import { getUser } from '../../api'

/*
首页路由
*/

const style__ = { "width": "100%" }

export default class User extends Component {

    componentDidMount() {
        getUser().then(res => {
            console.log(res.data)
            console.log(this.state.dataSource.index)
            this.setState({
            dataSource:res.data
            })
        })
    }

    state = {
        dataSource: [],
        columns: [
            {
                title: 'Id',
                width: 140,
                align: "center",
                dataIndex: 'id',
                key: 'id'
            },
            {
                title: '姓名',
                align: "center",
                width: 120,
                dataIndex: 'name',
                key: 'name'
            },
            {
                title: '游戏ID',
                align: "center",
                width: 120,
                ellipsis: "ture",
                dataIndex: 'playId',
                key: 'playId'
            },
            {
                title: '位置',
                width: 140,
                ellipsis: "ture",
                align: "center",
                dataIndex: 'position',
                key: ' position'
            },
            {
                title: '常用英雄',
                align: "center",
                width: 160,
                ellipsis: "ture",
                dataIndex: 'hero',
                key: 'hero'
            }
        ]
    }

    render() {
        return (
            <div>
                <Table className="table" bordered="ture"
                    columns={this.state.columns}
                    dataSource={this.state.dataSource}>
                </Table>
            </div>
        )
    }
}
